package controller.link.game;

import view.client.Console;
import model.Hearer;
import java.io.Serializable;
import controller.Link;
import model.User;
import model.Attendant;
import model.Server;

public class ChallengeRejected implements Link, Serializable {

    private String nameDesafiante;

    public ChallengeRejected(String nameDesafiante) {
        this.nameDesafiante = nameDesafiante;
    }

    public ChallengeRejected(Hearer h, String nameDesafiante) {
        this.nameDesafiante = nameDesafiante;
        h.send((Link) this);
    }

    @Override
    public void serverUse(Server server, Attendant at) {
        User user = at.getUser();
        if (!server.testName(nameDesafiante)) {
            server.searchAtendente(nameDesafiante).send((Link) this);
        }
    }

    @Override
    public void clientUse(Console console) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
